package com.acxy.ants.core.plugin.cron4j;

import java.util.Map;
import java.util.Timer;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author MrShun
 * @version 1.0
 * @Date 2017-06-16
 */
public class TaskKit {

    private final static ConcurrentHashMap<String, Timer> tasks = new ConcurrentHashMap();

    public static Timer get(String name){
        return tasks.get(name);
    }

    public static void set(String name, Timer timer){
        tasks.put(name, timer);
    }

    public static void stop(){
        for(Map.Entry<String, Timer> entry: tasks.entrySet())
            entry.getValue().cancel();
    }

    public static void stop(String name){
        tasks.get(name).cancel();
    }
}
